package com.atguigu.service.Impl;

import com.atguigu.dao.AdminDao;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.HouseBrokerDao;
import com.atguigu.entity.Admin;
import com.atguigu.entity.HouseBroker;
import com.atguigu.service.HouseBrokerService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.List;

/**
 * @title：
 * @author：Yu
 * @create：2023-02-15 10:58
 * @description：
 */
@DubboService
public class HouseBrokerSerivceImpl extends BaseServiceImpl<HouseBroker> implements HouseBrokerService {
    @Autowired
    private HouseBrokerDao houseBrokerDao;
    @Autowired
    private AdminDao adminDao;

    @Override
    public BaseDao<HouseBroker> getBaseDao() {
        return houseBrokerDao;
    }

    @Override
    public List<HouseBroker> findBroker(Long id) {
        return houseBrokerDao.findBroker(id);
    }

    @Override
    public List<Admin> findOtherBroker(Long id) {
        //查询该house_id所对应的brokerid
        List<Long> brokerIds = houseBrokerDao.findBrokerIdByHouseId(id);
        //查询不包含上面brokerids的代理人信息
        List<Admin> adminList = adminDao.findAllById(brokerIds);
        return adminList;
    }

    @Override
    public List<HouseBroker> findBrokersByHouseId(Long id) {
        List<HouseBroker> brokersByHouseId = houseBrokerDao.findBrokersByHouseId(id);
        return brokersByHouseId;
    }
}
